import { defineStore } from 'pinia';

// 记录标签栏的选择变化
interface navBarSelectState {
  selected:number
}

const initializeSelected=()=>{
  const currentURL = window.location.href;
  if (currentURL.includes('index')) {
    return 0
  } else if (currentURL.includes('reservePage')) {
    return 1
  }else if (currentURL.includes('articlePage')) {
    return 2
  }else if (currentURL.includes('noticePage')) {
    return 3
  }else {
    return -1
  }
}

export const navBarSelectState = defineStore('navBarSelect', {
  state: (): navBarSelectState => ({
    selected: initializeSelected(),
  }),
  actions: {
    setSelected(selected: number) {
      this.selected = selected;
    },
   
  },
});